home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / nihcl-30.lha / nihcl-3.0 / lib / Semaphore.h < prev    next >
C/C++ Source or Header  |  1990-05-20  |  2KB  |  64 lines

  1. #ifndef    SEMAPHORE_H
  2. #define    SEMAPHORE_H
  3.  
  4. /*$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/Semaphore.h,v 3.0 90/05/20 13:37:16 kgorlen Rel $*/
  5.  
  6. /* Semaphore.h -- declarations for Semaphore
  7.  
  8.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  9.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  10.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  11.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  12.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  13.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  14.  
  15. Author:
  16.     K. E. Gorlen
  17.     Computer Systems Laboratory, DCRT
  18.     National Institutes of Health
  19.     Bethesda, MD 20892
  20.  
  21. $Log:    Semaphore.h,v $
  22.  * Revision 3.0  90/05/20  13:37:16  kgorlen
  23.  * Release for 1st edition.
  24.  * 
  25. */
  26.  
  27. #include "Object.h"
  28. #include "LinkedList.h"
  29.  
  30. class Process;
  31.  
  32. class Semaphore: public VIRTUAL Object {
  33.     DECLARE_MEMBERS(Semaphore);
  34.     LinkedList waitList;
  35.     short count;
  36. protected:        // storer() functions for object I/O
  37.     virtual void storer(OIOofd&) const;
  38.     virtual void storer(OIOout&) const;
  39. public:
  40.     Semaphore(int initialCount =0);
  41. #ifndef BUG_TOOBIG
  42. // yacc stack overflow
  43.     Semaphore(const Semaphore&);
  44. #endif
  45.     ~Semaphore();
  46.     virtual Object* copy() const;        // deepCopy()
  47.     virtual void deepenShallowCopy();
  48.     virtual void dumpOn(ostream& strm =cerr) const;
  49.     virtual unsigned hash() const;
  50.     virtual bool includes(const Process&) const;
  51.     virtual bool isEqual(const Object& ob) const;
  52.     virtual void printOn(ostream& strm =cout) const;
  53.     virtual Process* remove(Process&);
  54.     virtual Process* removeFirst();
  55.     virtual Process* removeLast();
  56.     virtual void signal(unsigned n=1);  // signal waiting process 
  57.     virtual int value() const;    // read semaphore value 
  58.     virtual void wait();        // wait on semaphore 
  59. private:                // shouldNotImplement()
  60.     virtual int compare(const Object&) const;
  61. };
  62.  
  63. #endif
  64.